using System.Collections.Generic;
using System.Text.Encodings.Web;
using AAA.Db;
using AAA.Models;
using Microsoft.AspNetCore.Mvc;


namespace AAA.Controllers
{
    public class PointController:Controller
    {
        /* public string aa()
        {
            return "哈哈哈哈哈哈哈哈哈哈哈";
        } */

        /* public IActionResult aa()
        {
            return View("hhh");
        } */

        /* public string aa(string name,int nametime=1)    //http://localhost:5000/point/aa?name=ljy&nametime=100
        {
            return HtmlEncoder.Default.Encode($"Hello {name}, NumTimes is: {nametime}");
        } */  

        /* public IActionResult aa(int id)   //id='100'
        {
            return View("jiujiu");
        } */
        
        /* public IActionResult aa([FromQuery] string id)    //id='100'
        {
            //var id=Request.Query["id"];
            //var name=Request.QueryString["name"];
            //var sex=Request.params["sex"];
            return View("jiuijiu");
        } */

        /* public IActionResult aa()
        {
            var id=Request.Query["id"].ToString(); //id='100'   去掉.ToString(),id={100}
            return View("jiujiu");
        } */

        /* public IActionResult aa()
        {
            var id=Request.Query["id"][0]; //id='100'  
            return View("jiujiu");
        } */

        /* public IActionResult aa()
        {
            ViewBag.username="辣椒油";   //输出辣椒油，与jiuijiu关联
            return View("jiujiu");
        } */

        public IActionResult aa(int id)
        {          
            //ViewBag.username=id.ToString();     //http://localhost:5000/point/aa/555  输出555
           //var list=new List<int>{1,2,3,4,5};
              //根据jiujiu里的代码<li>依次输出12345
            var db=new DemoDb();
            var gradeCLass=new GradeClass{
                ClassName="20级软件1班",
                StudentNumber=46
            };
            db.GradeClasse.Add(gradeCLass);
            db.SaveChanges();
            var students=new List<Student>
            {
                new Student
                {
                    
                    Name="小一",
                    Adress="福建省",
                    Sex="男",
                    Touxiang="该用户未上传头像",
                    Age=16,
                    GradeClassId=gradeCLass.Id
                },
                new Student
                {
                    
                    Name="小二",
                    Adress="广东省",
                    Sex="男",
                    Touxiang="因太帅未上传头像",
                    Age=18,
                    GradeClassId=gradeCLass.Id
                },
                new Student
                {
                    
                    Name="小三",
                    Adress="天津省",
                    Sex="女",
                    Touxiang="因太丑未上传头像",
                    Age=13,
                    GradeClassId=gradeCLass.Id
                },
                new Student
                {
                    
                    Name="小四",
                    Adress="河北省",
                    Sex="男",
                    Touxiang="太懒",
                    Age=56,
                    GradeClassId=gradeCLass.Id
                },
            };
            /* ViewBag.username=id.ToString(); 
            ViewBag.ids=list;  
            ViewBag.Student=students;  */
            db.Student.AddRange(students);
            db.SaveChanges();
            return View("jiujiu",students);
        }
    } 
}